from django import forms
from .models import User


class LoginForm(forms.ModelForm):
    # 'telphone': [{'message': 'User with this Telphone already exists.', 'code': 'unique'}]
    # TODO: 自定义接收telphone字段进行表单验证
    telphone = forms.CharField(max_length=11, min_length=11)
    # TODO: required不是必选参数
    remember = forms.BooleanField(required=False)

    class Meta:
        model = User
        # TODO: 校验字段
        # telphone排除数据库进行了unique字段现在，所以只能通过自定义接收字段进行表单验证
        fields = ['password']
